const { app, globalShortcut } = require('electron');
const imageWindow = require('./windows/image_window');

class JHWallpaper {

    constructor () {
        this.window = null;
        this.initApp();
    }

    initApp () {
        app.on('ready', () => {
            this.createWindow();
        });
        app.on('activate', () => {
            if (!this.window) {
                this.createWindow();
            } else {
                this.window.show()
            }
        });
        app.on('window-all-closed', () => {
            globalShortcut.unregisterAll();
            app.quit()
        });
    }

    createWindow () {
        this.window = new imageWindow();
        this.window.createWindow();
        this.window.ipc();
        this.window.shortcut();
        this.window.show();
    }
}

new JHWallpaper();
